package com.newidea.jiangong.dto;

import com.newidea.jiangong.utils.HeatFacilityUtil;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.List;
import java.util.Map;

@Schema(title = "锅炉")
@Data
public class Boiler {

    @Schema(title = "锅炉名称")
    private String name;

    @Schema(title = "供水温度")
    private String supplyWaterTemperature;

    @Schema(title = "回水温度")
    private String returnWaterTemperature;

    @Schema(title = "供水压力")
    private String supplyWaterPressure;

    @Schema(title = "回水压力")
    private String returnWaterPressure;

    @Schema(title = "供水流量")
    private String supplyWaterQuantity;

    @Schema(title = "回水流量")
    private String returnWaterQuantity;

    @Schema(title = "冷凝进口烟温值")
    private String condenserInTemperature;

    @Schema(title = "冷凝出口烟温值")
    private String condenserOutTemperature;

    @Schema(title = "冷凝出水水温")
    private String condenserEffluentTemperature;

    @Schema(title = "炉膛温度")
    private String furnaceTemperature;

    @Schema(title = "炉膛压力")
    private String furnacePressure;

    @Schema(title = "燃气流量")
    private String fuelGasQuantity;

    @Schema(title = "燃气用量")
    private String fuelGasDosage;

    @Schema(title = "鼓风频率")
    private String forcedDraftFrequency;

    @Schema(title = "额定功率")
    private String ratedPower;

    @Schema(title = "排烟压力")
    private String ejectSmokePressure;

    @Schema(title = "排烟温度")
    private String ejectSmokeTemperature;

    @Schema(title = "排烟湿度")
    private String ejectSmokeHumidity;

    @Schema(title = "NO x浓度")
    private String noxConcentration;

    @Schema(title = "干烟气中含氧量")
    private String dryFlueGasOxygen;

    /**
     * 创建锅炉实体
     *
     * @param name              锅炉名称
     * @param facilityMap       设备地址:值
     * @param boilerAddressList 锅炉设备地址集合
     * @return 锅炉实体
     */
    public static Boiler createBoiler(
        String name, Map<String, String> facilityMap, List<String> boilerAddressList
    ) {
        // 地址角标，facilityMap每取一次都要加1
        int index = 0;
        Boiler boiler = new Boiler();
        // 名称
        boiler.setName(name);
        // 供水温度
        boiler.setSupplyWaterTemperature(HeatFacilityUtil.getStateName(facilityMap, boilerAddressList, index++));
        // 回水温度
        boiler.setReturnWaterTemperature(HeatFacilityUtil.getStateName(facilityMap, boilerAddressList, index++));
        // 供水压力
        boiler.setSupplyWaterPressure(HeatFacilityUtil.getStateName(facilityMap, boilerAddressList, index++));
        // 回水压力
        boiler.setReturnWaterPressure(HeatFacilityUtil.getStateName(facilityMap, boilerAddressList, index++));
        // 供水流量
        boiler.setSupplyWaterQuantity(HeatFacilityUtil.getStateName(facilityMap, boilerAddressList, index++));
        // 回水流量
        boiler.setReturnWaterQuantity(HeatFacilityUtil.getStateName(facilityMap, boilerAddressList, index++));
        // 冷凝进口烟温值
        boiler.setCondenserInTemperature(HeatFacilityUtil.getStateName(facilityMap, boilerAddressList, index++));
        // 冷凝出口烟温值
        boiler.setCondenserOutTemperature(HeatFacilityUtil.getStateName(facilityMap, boilerAddressList, index++));
        // 冷凝出水水温
        boiler.setCondenserEffluentTemperature(HeatFacilityUtil.getStateName(facilityMap, boilerAddressList, index++));
        // 炉膛温度
        boiler.setFurnaceTemperature(HeatFacilityUtil.getStateName(facilityMap, boilerAddressList, index++));
        // 炉膛压力
        boiler.setFurnacePressure(HeatFacilityUtil.getStateName(facilityMap, boilerAddressList, index++));
        // 燃气流量
        boiler.setFuelGasQuantity(HeatFacilityUtil.getStateName(facilityMap, boilerAddressList, index++));
        // 燃气用量
        boiler.setFuelGasDosage(HeatFacilityUtil.getStateName(facilityMap, boilerAddressList, index++));
        // 鼓风频率
        boiler.setForcedDraftFrequency(HeatFacilityUtil.getStateName(facilityMap, boilerAddressList, index++));
        // 额定功率
        boiler.setRatedPower(HeatFacilityUtil.getStateName(facilityMap, boilerAddressList, index++));
        // 排烟压力
        boiler.setEjectSmokePressure(HeatFacilityUtil.getStateName(facilityMap, boilerAddressList, index++));
        // 排烟温度
        boiler.setEjectSmokeTemperature(HeatFacilityUtil.getStateName(facilityMap, boilerAddressList, index++));
        // 排烟湿度
        boiler.setEjectSmokeHumidity(HeatFacilityUtil.getStateName(facilityMap, boilerAddressList, index++));
        // NO x浓度
        boiler.setNoxConcentration(HeatFacilityUtil.getStateName(facilityMap, boilerAddressList, index++));
        // 干烟气中含氧量
        boiler.setDryFlueGasOxygen(HeatFacilityUtil.getStateName(facilityMap, boilerAddressList, index));
        return boiler;
    }
}
